/**    
 * 文件名：BillManageService.java</br>
 *    
 * 版本信息：v1.0</br>
 * 日期：2017年7月14日</br>
 * © 2005-2017 雷技信息科技（上海）有限公司版权所有</br>
 *
 */
package com.logic.landseaserver.models.billmanage.service;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.logic.common.security.SecurityUtils;
import com.logic.common.util.QueryUtil;
import com.logic.landseaserver.common.exception.LandseaException;
import com.logic.landseaserver.common.exception.ResultCodes.BillManageResultCode;
import com.logic.landseaserver.common.exception.ResultCodes.CommonResultCode;
import com.logic.landseaserver.domain.BalanceSheetRecord;
import com.logic.landseaserver.persistence.read.BalanceSheetRecordReadMapper;

/**
 *
 * 项目名称：system-server</br>
 * 类名称：BillManageService</br>
 * 类描述：</br>
 * 创建人：Aaron</br>
 * 创建时间：2017年7月14日 下午4:14:36</br>
 * 
 * @version 1.0
 *
 */
@Service
public class BillManageService
{
    private static final Logger LOG = LoggerFactory.getLogger(BillManageService.class);
    
    @Autowired
    private BalanceSheetRecordReadMapper balanceSheetRecordReadMapper;
    
    /**
     * 
     * [简要描述]：根据条件查询账单</br>
     * [详细描述]：查询独立账单</br>
     * [作者]：Aaron(2017-07-14)</br>
     *
     * @param condition 条件对象
     * @throws LandseaException
     *
     */
    public List<BalanceSheetRecord> queryBillByCondition(QueryUtil condition)
        throws LandseaException
    {
        try
        {
            Integer systemId = SecurityUtils.getCurrentLogin().getUserId();
            if (systemId == null)
            {
                throw LandseaException.createException(CommonResultCode.E00000403);
            }
            // 添加权限
            Map<String, Object> params = condition.getParams();
            params.put("adminId", systemId); 
           // return viewBillRecordMapper.queryByCondition(condition);
            return balanceSheetRecordReadMapper.queryByCondition(condition);
        }
        catch (Exception e)
        {
            LOG.error("BillManageService|query bill by condition failed." + condition.toString(), e);
            throw LandseaException.createException(BillManageResultCode.E00250000, e);
        }
    }
}
